package app_config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MysqlConfig
	RedisConfig
}

type MysqlConfig struct {
	Host     string
	Port     int
	User     string
	Password string
	DdName   string
}

type RedisConfig struct {
	Host     string
	Port     int
	Password string
	DB       int
}

var AppConf AppConfig

func InitApp() {
	viper.SetConfigFile("./app_config/app.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("动态配置文件获取失败", err)
		return
	}
	viper.Unmarshal(&AppConf)
	fmt.Println("动态配置文件获取成功", AppConf)
}
